<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/playcanvas-stable.js"></script>
</head>

<body>
    <canvas id="application-canvas"></canvas>
    <script>
        // Create a PlayCanvas application
        var canvas = document.getElementById("application-canvas");
        var app = new pc.fw.Application(canvas, {});
        app.start();

        // Fill the available space at full resolution
        app.setCanvasFillMode(pc.fw.FillMode.FILL_WINDOW);
        app.setCanvasResolution(pc.fw.ResolutionMode.AUTO);

        // Create box entity
        var cube = new pc.fw.Entity();
        app.context.systems.model.addComponent(cube, {
            type: "box"
        });

        // Create camera entity
        var camera = new pc.fw.Entity();
        app.context.systems.camera.addComponent(camera, {
            clearColor: new pc.Color(0.1, 0.2, 0.1)
        });

        // Create directional light entity
        var light = new pc.fw.Entity();
        app.context.systems.light.addComponent(light);

        // Add to hierarchy
        app.context.root.addChild(cube);
        app.context.root.addChild(camera);
        app.context.root.addChild(light);

        // Set up initial positions and orientations
        camera.setPosition(0, 0, 3);
        light.setEulerAngles(45, 0, 0);

        // Register an update event
        app.on("update", function (deltaTime) {
            cube.rotate(10 * deltaTime, 20 * deltaTime, 30 * deltaTime);//
            // camera.rotate(10 * deltaTime, 20 * deltaTime, 30 * deltaTime)
        });

    </script>
</body>

</html>